﻿#region zh-CHS 2006 - 2007 DemoSoft 团队 | en 2006 - 2007 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the G.O.S.E(Game Online Server Engine) for .NET.
//
//                 2006-2007 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System;
using System.Threading;
#endregion

namespace Demo_G.O.S.E.ServerEngine.Item
{
    /// <summary>
    /// BaseItem Delta
    /// </summary>
    public class BaseItemDelta : IItemDelta
    {
        #region zh-CHS 共有属性 | en Public Properties

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateX = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool X
        {
            get { return m_UpdateX; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaX = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaX
        {
            get { return m_IsDeltaX; }
            set { m_IsDeltaX = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateY = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Y
        {
            get { return m_UpdateY; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaY = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaY
        {
            get { return m_IsDeltaY; }
            set { m_IsDeltaY = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateZ = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Z
        {
            get { return m_UpdateZ; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaZ = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaZ
        {
            get { return m_IsDeltaZ; }
            set { m_IsDeltaZ = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateLocation = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Location
        {
            get { return m_UpdateLocation; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaLocation = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaLocation
        {
            get { return m_IsDeltaLocation; }
            set { m_IsDeltaLocation = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateDirection = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Direction
        {
            get { return m_UpdateDirection; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaDirection = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaDirection
        {
            get { return m_IsDeltaDirection; }
            set { m_IsDeltaDirection = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateSerial = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Serial
        {
            get { return m_UpdateSerial; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaSerial = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaSerial
        {
            get { return m_IsDeltaSerial; }
            set { m_IsDeltaSerial = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateMap = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Map
        {
            get { return m_UpdateMap; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaMap = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaMap
        {
            get { return m_IsDeltaMap; }
            set { m_IsDeltaMap = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateName = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Name
        {
            get { return m_UpdateName; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaName = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaName
        {
            get { return m_IsDeltaName; }
            set { m_IsDeltaName = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateVisible = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Visible
        {
            get { return m_UpdateVisible; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaVisible = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaVisible
        {
            get { return m_IsDeltaVisible; }
            set { m_IsDeltaVisible = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateItemDelta = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool ItemDelta
        {
            get { return m_UpdateItemDelta; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaItemDelta = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaItemDelta
        {
            get { return m_IsDeltaItemDelta; }
            set { m_IsDeltaItemDelta = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateParent = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Parent
        {
            get { return m_UpdateParent; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaParent = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaParent
        {
            get { return m_IsDeltaParent; }
            set { m_IsDeltaParent = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateLayer = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool Layer
        {
            get { return m_UpdateLayer; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaLayer = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaLayer
        {
            get { return m_IsDeltaLayer; }
            set { m_IsDeltaLayer = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateIsVirtualItem = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsVirtualItem
        {
            get { return m_UpdateIsVirtualItem; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaIsVirtualItem = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaIsVirtualItem
        {
            get { return m_IsDeltaIsVirtualItem; }
            set { m_IsDeltaIsVirtualItem = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateAddChildItemCall = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool AddChildItemCall
        {
            get { return m_UpdateAddChildItemCall; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaAddChildItemCall = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaAddChildItemCall
        {
            get { return m_IsDeltaAddChildItemCall; }
            set { m_IsDeltaAddChildItemCall = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_UpdateRemoveChildItemCall = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool RemoveChildItemCall
        {
            get { return m_UpdateRemoveChildItemCall; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsDeltaRemoveChildItemCall = false;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsDeltaRemoveChildItemCall
        {
            get { return m_IsDeltaRemoveChildItemCall; }
            set { m_IsDeltaRemoveChildItemCall = value; }
        }

        #endregion

        #region zh-CHS 共有方法 | en Public Methods
        /// <summary>
        /// 
        /// </summary>
        public void UpdateX()
        {
            m_UpdateX = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreX()
        {
            m_UpdateX = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateY()
        {
            m_UpdateY = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreY()
        {
            m_UpdateY = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateZ()
        {
            m_UpdateZ = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreZ()
        {
            m_UpdateZ = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateLocation()
        {
            m_UpdateLocation = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreLocation()
        {
            m_UpdateLocation = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateDirection()
        {
            m_UpdateDirection = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreDirection()
        {
            m_UpdateDirection = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateSerial()
        {
            m_UpdateSerial = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreSerial()
        {
            m_UpdateSerial = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateMap()
        {
            m_UpdateMap = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreMap()
        {
            m_UpdateMap = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateName()
        {
            m_UpdateName = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreName()
        {
            m_UpdateName = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateVisible()
        {
            m_UpdateVisible = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreVisible()
        {
            m_UpdateVisible = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateItemDelta()
        {
            m_UpdateItemDelta = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreItemDelta()
        {
            m_UpdateItemDelta = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateParent()
        {
            m_UpdateParent = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreParent()
        {
            m_UpdateParent = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateLayer()
        {
            m_UpdateLayer = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreLayer()
        {
            m_UpdateLayer = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateIsVirtualItem()
        {
            m_UpdateIsVirtualItem = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreIsVirtualItem()
        {
            m_UpdateIsVirtualItem = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateAddChildItemCall()
        {
            m_UpdateAddChildItemCall = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreAddChildItemCall()
        {
            m_UpdateAddChildItemCall = false;
        }

        /// <summary>
        /// 
        /// </summary>
        public void UpdateRemoveChildItemCall()
        {
            m_UpdateAddChildItemCall = true;
        }

        /// <summary>
        /// 
        /// </summary>
        public void RestoreRemoveChildItemCall()
        {
            m_UpdateAddChildItemCall = false;
        }
        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_bIsLockThis = false;
        /// <summary>
        /// 
        /// </summary>
        private object m_LockThis = new object();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool LoginDeltaQueue()
        {
            bool bReturn = false;

            if ( Monitor.TryEnter( m_LockThis ) == false )
                return false;
            else
            {
                if ( m_bIsLockThis == false ) // 没有锁定
                    bReturn = m_bIsLockThis = true;
            }
            Monitor.Exit( m_LockThis );

            return bReturn;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool IsLoginDeltaQueue()
        {
            return m_bIsLockThis;
        }

        /// <summary>
        /// 
        /// </summary>
        public void LogoutDeltaQueue()
        {
            Monitor.Enter( m_LockThis );
            {
                m_bIsLockThis = false;
            }
            Monitor.Exit( m_LockThis );
        }

        #endregion
    }
}
#endregion

